<!doctype html>
<html lang="en" xmlns:th="https://www.thymeleaf.org">

<!-- head -->
<div th:replace="~{include/include-head :: head}"></div>

<body>
<!-- topbar -->
<div th:replace="~{include/include-nav :: nav}"></div>

<div class="container-fluid">
    <div class="row">
        <!-- sidebar -->
        <div th:replace="~{include/include-sidebar :: sidebar}"></div>
        <main role="main" class="col-md-9 ml-sm-auto col-lg-10 pt-3 px-4">
            <h2><a class="btn btn-sm btn-success" href="emp" th:href="@{/emp}">员工添加</a></h2>
            <div class="table-responsive">
                <table class="table table-striped table-sm">
                    <thead>
                    <tr>
                        <th>#</th>
                        <th>lastName</th>
                        <th>email</th>
                        <th>gender</th>
                        <th>department</th>
                        <th>birth</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr th:each="emp:${emps}">
                        <td th:text="${emp.empId}"></td>
                        <td>[[${emp.empName}]]</td>
                        <td th:text="${emp.email}"></td>
                        <td th:text="${emp.gender}==0?'女':'男'"></td>
                        <td th:text="${emp.department.DName}"></td>
                        <td th:text="${#dates.format(emp.date, 'yyyy-MM-dd HH:mm')}"></td>
                        <td>
                            <a class="btn btn-sm btn-primary" th:href="@{/emp/}+${emp.empId}">编辑</a>
                            <form th:action="@{/emp/}+${emp.empId}" id="deleteEmpForm"  method="post">
                                <input type="hidden" name="_method" value="delete"/>
                                <button type="submit" class="btn btn-sm btn-danger">删除</button>
                            </form>
                        </td>
                    </tr>
                    </tbody>
                </table>
            </div>
        </main>
    </div>
</div>
<script src="dashboard.js" th:src="@{/js/main.js}"></script>
</body>
</html>